package com.hxy.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxy.dao.RprecordMapper;
import com.hxy.pojo.Rpkind;
import com.hxy.pojo.Rprecord;
import com.hxy.pojo.Trainnote;
import com.hxy.pojo.model.GetUtilPagerequest;
import com.hxy.pojo.model.RprecordPagerequest;
import com.hxy.pojo.vo.RprecordVo;
import com.hxy.pojo.vo.StuffinfoVo;
import com.hxy.pojo.vo.TrainnoteVo;
import com.hxy.service.RprecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class RprecordServiceImpl implements RprecordService {
    @Autowired
    private RprecordMapper rprecordMapper;

    @Override
    public PageInfo<RprecordVo> selectAll(Integer pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<RprecordVo> rprecordVoList = rprecordMapper.selectAll();
        PageInfo<RprecordVo> PageInfo = new PageInfo<>(rprecordVoList);
        return PageInfo;
    }

    @Override
    public PageInfo<RprecordVo> selectByTj(Integer page, int limit, Integer eid, String stuffinfoName,
                                              String startTime, String endTime, String rpKind, Integer status) {
        PageHelper.startPage(page, limit);
        RprecordVo rprecordVo = new RprecordVo(eid, stuffinfoName, startTime, endTime, rpKind, status);
        List<RprecordVo> rprecordVoList = rprecordMapper.selectByTJ(rprecordVo);
        PageInfo<RprecordVo> PageInfo = new PageInfo<>(rprecordVoList);
        return PageInfo;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return rprecordMapper.deleteById(id);
    }

    @Override
    public int addRprecord(Integer eid, Integer rpkindid) {
        return rprecordMapper.insert(eid,rpkindid);
    }

    @Override
    public int update(RprecordVo Rprecord) {
        return rprecordMapper.update(Rprecord);
    }

    @Override
    public RprecordVo selectById(Integer id) {
        return rprecordMapper.selectById(id);
    }
}
